package com.ciei.dpagm.service;

import com.ciei.dpagm.common.token.StatelessToken;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;


/**
 * @author pp
 * @date 2022-9-7
 */
@Service
public class LoginService {

    /**
     * 无状态(C端入口)登录
     * @param userId
     * @param userName
     * @param access
     */
    public void login(String userId,String userName,String access){
        userName = StringUtils.isBlank(userName) ? userId : userName;
        StatelessToken token = new StatelessToken(userId,userName,access);
        Subject subject = SecurityUtils.getSubject();
        subject.login(token);
    }

}
